package com.hrt.web.addressBook.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.hrt.base.BaseDaoImpl;
import com.hrt.bean.AddressBook;
import com.hrt.web.addressBook.dao.AddressBookDao;
@Repository
public class AddressBookDaoImpl extends BaseDaoImpl<AddressBook> implements AddressBookDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<AddressBook> getAddListById(Long memberId) {
		String hql = "select book from AddressBook book where book.memberId='"+memberId+"' and book.isdelete=0";
		return getHibernateTemplate().find(hql);
	}

	@Override
	public AddressBook getDefaultAddress(Long memberId,Integer isdefault) {
		AddressBook addressBook = null;
		String hql = "select ad from AddressBook ad where ad.isdefault=1 and ad.isdelete=0 and ad.memberId='"+memberId+"'";
		List list =  getHibernateTemplate().find(hql);
		if(list!=null&&list.size()>0){
			addressBook = (AddressBook) list.get(0);
			}
		return addressBook;
	}

}
